1. Locate and edit the General Parameters group in the executable.py file:
@engine.parameter_group( name="general_parameters", display_name="General Parameters", description="Parameters for Hello World", parameter_group=ParameterGroup( Parameter( type=Int(), name="repeat", display_name="Repeat", description="Specify how many times to print.", default=1, required=True, ), Parameter( type=String(), name="name", display_name="Name", description="Specify a name to print instead of World.", required=False, ), ), )
@engine.parameter_group( name="general_parameters", display_name="General Parameters", description="Parameters for Hello World", parameter_group=ParameterGroup( Parameter( type=Int(), name="repeat", display_name="Repeat", description="Specify how many times to print.", default=1, required=True, ), Parameter( type=String(), name="name", display_name="Name", description="Specify a name to print instead of World.", required=False, ), Parameter( type=SlackAPIConnection, name="slack_connection", display_name="Slack Connection", description="Select the Slack workspace to use.", required=True, ), Parameter( type=String(), name="channel", display_name="Channel", description="Specify the Slack channel name to print in.", required=True, ), ), )
SlackAPIConnection = Connection( alias="Slack:API:Token", description="Slack API token.", connection_type_uuid="SLKTK-O2B8D", categories=["API", "Slack"], parameter_groups=[ ParameterGroup( Parameter( name="token", display_name="Token", description="Token string used to connect to Slack REST API's.", type=String(), required=True, ), name="slack_parameters", display_name="Slack Parameters", ), ], )
def hello_world(parameters): i = 0 x = f"Hello {parameters.get('name', 'World')}" while i < parameters["repeat"]: logger.info(x) i += 1 return i, x
def hello_world(parameters): i = 0 x = f"Hello {parameters.get('name', 'World')}" client = slack.WebClient(token=parameters["slack_connection"]["token"]) while i < parameters["repeat"]: logger.info(x) client.chat_postMessage(channel=parameters["channel"], text=x) i += 1 return i, x
import logging
from nomnomdata.engine.components import Engine, Parameter, ParameterGroup
from nomnomdata.engine.parameters import Int, String
import logging
import slack
from nomnomdata.engine.components import Engine, Parameter, ParameterGroup, Connection
from nomnomdata.engine.connections import SlackAPIConnection
from nomnomdata.engine.parameters import Int, String
slackclient==2.5.0