Key Concepts
- Serverless Execution: The code is hosted and run by DailyBot in a serverless environment, ensuring scalability and ease of maintenance.
- Triggering Commands: The code executes in response to chat commands or scheduled events.
- Dynamic Responses: The program can return text messages or JSON objects with interactive elements like buttons for chat.
- Event Data and Parameters: Commands context can include parameters for dynamic execution.
- HTTP Requests: The Code supports HTTP requests to external APIs or URLs.
- DailyBotSDK: We provide a convenient interface for storage operations, scheduling tasks, and sending messages.
Running a command
- In-Chat Command Trigger: Initiate code execution via chat commands. On DM or channels.
- Workflow Trigger: Run the code in response to specific events or schedules via DailyBot Workflows.
- Command Scheduler: Use the DailyBot SDK to schedule a future run of a command.
Command input
A user can simply run the command by typing the command intent, users can also type the intent and additional words.
Command intent query string
The additional words and query string are captured and can be accessed in the event.query variable.
For example, your command name is "growth_rate", and a user types "growth_rate July, August". In this case, the event.query will have the string "July, August".
Capture user input and context:
Context variables for the command
event.data.intent: The actual command name being triggered
event.data.user_full_name: The name of user triggering the command
event.data.targetChannel: The chat channel object where the command was run
Making HTTP requests to internet services
Utilize request for API interactions. The request variable is a wrapper of the JS superagent library:
Returning the result of the command
Your command can respond with a string:
Or your command can return with a JSON special object that provides text responses and interactive buttons:
When you utilize the JSON response with interactive buttons, the "value" can be a reference to the same command intent with different query parameters. This way you can build more complex flows using one single code command.
DailyBotSDK
We provide a simple SDK that you can use to interact with the DailyBot platform.
Import and Initialization
Key-value storage
You can store JSON {} objects in item keys that are associated with the user making the request/interacting with the chat command.
- Write: Store data associated with a key.
- Read: Retrieve data by key.
- Delete: Remove data by key.
Example
Booking a room
Users can book a meeting room by typing book_room [room_name] [date] [time]:
Tech news update
Users can get the latest tech news by typing tech_news: