A text command simply responds to the user immediately with a text that you have predefined in the command configuration. These kind of commands are useful for having frequent text, links or information that your team needs to access on a recurring basis.
For example: you can create a text command named "manifesto" that responds with a text description of what your company manifesto is. Users will be able to use that command in channels or from private conversations with DailyBot.
It is possible to create commands that trigger a native in-chat form that you build with DailyBot. With DailyBot forms and commands you can build use cases based on data that you collect through the chat, the you enter in a Form will be stored in a DailyBot table, and you can use DailyBot to also search for responses stores in that Form.
On the web application, navigate to the "Forms" section to learn more. If you want to search across the form responses, type the command name followed by the keyword "search" and then your query.
Example: if your command to trigger a form is named "inventory", you can also type "inventory search my_keyword" - DailyBot will give you the responses that match with your search.
The HTTP Commands let you process a DailyBot command with an app (endpoint) of your own creation, and then respond with dynamic information. This is very powerful and useful for many use cases.
For example: you can create an HTTP command named "sales" and implement your logic to return the key metrics, so users can access this information in a simple way just using DailyBot, from their own chat app (desktop or mobile).
You can even use HTTP commands for ChatOps: implementing custom workflows and operations of your company that run entirely on the chat. More examples include: deploying an app, getting the version of an app, showing analytics, seeing a repository active branches, etc.
Your endpoint implementation must be HTTPS (mandatory) - and you can configure the HTTP method you want to trigger, on the web application.
Once a command is processed, DailyBot delivers a payload to your endpoint, including special HTTP headers.
X-DailyBot-Signature: String
The X-DailyBot-Signature header will include your Command signature. You can get the signature by opening your command (in the web app, edit mode) and then clicking the "view signature" link.
Recommendation: use the signature header in your endpoint to validate that the request is authentic.
The payload will include basic information for you to identify the user and the DailyBot workspace. It also defines whether the message is coming from a public channel.
Request body (payload) example:
These are the fields:
Notice you can build your command to implement more complex logic, using the params.query object.
When users use the command, they can include more words or numbers after the command invocation (separated with a space).
Example:
As you can see, you can use one only Command in DailyBot to build complex utilities that can react to multiple parameters.
💡 Recommendation:
If you are developing any complex logic and your command will support several parameters, consider adding a "help" keyword to give instructions to the users about how to use the command logic.
The Content-Type should always be application/json.
Your endpoint can use different formats to respond to the command's request:
The simplest method, just make sure your endpoint responds with a text body (as a JSON valid string). DailyBot will render that text to the user. You can also use simple markdown.
Hi, this is a *text response*.
Your endpoint can respond with a JSON object. You can specify what JSON field should be used as the response to be rendered to the user.
Configure the JSON response param in DailyBot's web app, at the command settings page:
Use a JSON to include a payload with a special format if you want to render buttons.
In case you are using a custom JSON Response Param, you must include this response payload in your JSON Response Param.
Notice that the buttons have to be an array, and each item will be a button, it includes these fields:
Let's see an example for the "sales" command, responding with a few buttons/choices for the user:
The following code will render these buttons:
Your endpoint should process the request and respond to DailyBot in less than 10 seconds.
Do you need to process a message for more than 10 seconds? It is possible to respond asynchronously, please contact our support team. This option is available but is not currently open for all developers.
We created a CodeSandbox project where you can see a Command implementation example in NodeJS.
https://codesandbox.io/s/dailybot-sample-command-demo-6nu1u
You can use CodeSandbox to clone the project (fork) and play with it yourself.