In this Quick Start, you'll send a Chat message that alerts you when inventory for an item falls below a threshold, as shown:
This quick start builds on Quick start: Create your first Chat app with AppSheet.
To send a Chat message from an automation:
- First, you need to create a Chat app. Follow the steps in Quick start: Create your first Chat app with AppSheet to create a Chat app using Simple inventory sample app.
- If you selected manual configuration to configure you Chat app, to support asynchronous interactions with your Chat app when sending Chat messages from an automation:
If you selected automatic configuration to configure you Chat app, you can skip this step.
- In the app editor, expand the Grant IAM access to run automations section on the Chat Setup page.
- Click Google Cloud Console > IAM & Admin > IAM to open the IAM & Admin page in the Google Cloud Console.
- Click Grant access.
The Grant access panel displays. - In the app editor, copy the New principal.
- In the console, paste it in the New principals field in the Add principals section.
- In the console, select Service Usage Consumer in the Role drop-down in the Assign roles section.
- Click Save.
- Return to the app editor and go to Automation > Bots.
The bot named When stock available of an item is below threshold, send an email is selected and displayed by default. You'll modify this bot to also send a Chat message. - In the process flow, click + Add a step.
- Select Run a task in the drop-down.
- Change the Step name to Send a Chat message.
- Under Task Settings, select Send a chat message.
- Configure the Chat message as follows:
Setting Description Table name Leave set to Inventory. Message Content Select Select chat spaces in the drop-down. Space ID(s) Click Add and select the Chat space you to which you added the Chat app in Quick start: Create your first Chat app with AppSheet. Message Text Set to: <<_APPNAME>> ALERT - <<[Item ID].[Name]>> inventory is below threshold Send an app view (optional) Select Inventory_Detail. - Save the app by selecting one of the following options:
- Save - Save the app.
- Save & verify data - Save the app and verify that it is runnable based on external dependencies.
- Go to the Chat space and enter /, select /inventory-form in the list, and press Enter.
- Click Open in app.
- Select Saw and set the Amount to any value, such as -83.
You can leave the DateTime field set to the default.
- Click Save.
- Return to the Chat space and notice that the inventory alert message is displayed with the Inventory_Detail chat card showing the details for the item.
Congratulations! You have successfully created your first Chat message from an automation with AppSheet!