- What's New
- Function Overview
- Service Overview
- Getting Started
-
User Guide
- Topic Management
- Subscription Management
- Message Template Management
- SMN Operation Recording
- Cloud Eye Monitoring
- Logs
- Permissions Management
- Quotas
- Appendix
- Best Practices
-
API Reference
- Before You Start
- API Overview
- Calling APIs
- Getting Started
- APIs
- Examples
- Permissions Policies and Supported Actions
- Public Parameters
- Out-of-Date APIs
- Appendix
- SDK Reference
-
FAQs
- What Are the Advantages of SMN?
- What Protocols Does SMN Support?
- How Is SMN Billed?
- What Are the Requirements for an SMN Topic Name?
- How Many Topics Can I Create?
- How Many Subscriptions Can Be Added to a Topic?
- How Many Messages Can Be Published to a Topic?
- How Many Message Templates Can I Create?
- What Are the Limitations on SMS Messages?
- Can I Add Subscriptions Using Multiple Protocols to a Topic?
- Can a Topic Creator Change Subscription Protocols in a Topic?
- Can I Change a Subscription Endpoint for a Topic?
- Can I Delete a Published Message?
- Does SMN Ensure That Messages Are Received by Subscription Endpoints?
- Will a Subscriber Receive the Same Message Multiple Times?
- Why Do Subscribers Fail to Receive Messages After I Publish Messages to a Topic?
- What Can I Do When Pictures in an Email Message Cannot Be Displayed?
- Does SMN Always Use the Same Phone Number or Sender Name to Send SMS Messages?
- How Do I Obtain My Account ID?
- How Does a DingTalk, Internal DingTalk, Lark, or WeCom Chatbot Obtain Subscription Endpoints?
- Videos
-
More Documents
-
User Guide (ME-Abu Dhabi Region)
- Overview
- Getting Started
- Topic Management
- Subscription Management
- Message Template Management
- SMN Operation Recording
- Logs
- Permissions Management
- Quotas
-
FAQs
- What Are the Advantages of SMN?
- What Protocols Does SMN Support?
- What Are the Requirements for an SMN Topic Name?
- How Many Topics Can I Create?
- How Many Subscriptions Can Be Added to a Topic?
- How Many Messages Can Be Published to a Topic?
- How Many Message Templates Can I Create?
- Can I Add Subscriptions Using Multiple Protocols to a Topic?
- Can a Topic Creator Change Subscription Protocols in a Topic?
- Can I Change a Subscription Endpoint for a Topic?
- Can I Delete a Published Message?
- Does SMN Ensure That Messages Are Received by Subscription Endpoints?
- Will a Subscriber Receive the Same Message Multiple Times?
- Why Do Subscribers Fail to Receive Messages After I Publish Messages to a Topic?
- What Can I Do When Pictures in an Email Message Cannot Be Displayed?
- How Do I Obtain My Account ID?
- Appendix
- Change History
- API Reference
-
User Guide (Paris Region)
- Overview
- Getting Started
- Topic Management
- Subscription Management
- Message Template Management
- SMN Operation Recording
- Logs
- Quotas
-
FAQs
- What Are the Advantages of SMN?
- What Protocols Does SMN Support?
- What Are the Requirements for an SMN Topic Name?
- How Many Topics Can I Create?
- How Many Subscriptions Can Be Added to a Topic?
- How Many Messages Can Be Published to a Topic?
- How Many Message Templates Can I Create?
- What Are the Limitations on SMS Messages?
- Can I Add Subscriptions Using Multiple Protocols to a Topic?
- Can a Topic Creator Change Subscription Protocols in a Topic?
- Can I Change a Subscription Endpoint for a Topic?
- Can I Delete a Published Message?
- Does SMN Ensure That Messages Are Received by Subscription Endpoints?
- Will a Subscriber Receive the Same Message Multiple Times?
- Why Do Subscribers Fail to Receive Messages After I Publish Messages to a Topic?
- What Can I Do When Pictures in an Email Message Cannot Be Displayed?
- How Do I Obtain My Account ID?
- Appendix
- Change History
- API Reference (Paris Region)
-
User Guide (Kuala Lumpur Region)
- Overview
- Getting Started
- Topic Management
- Subscription Management
- Message Template Management
- SMN Operation Recording
- Logs
- Permissions Management
- Quotas
-
FAQs
- What Are the Advantages of SMN?
- What Protocols Does SMN Support?
- What Are the Requirements for an SMN Topic Name?
- How Many Topics Can I Create?
- How Many Subscriptions Can Be Added to a Topic?
- How Many Messages Can Be Published to a Topic?
- How Many Message Templates Can I Create?
- Can I Add Subscriptions Using Multiple Protocols to a Topic?
- Can a Topic Creator Change Subscription Protocols in a Topic?
- Can I Change a Subscription Endpoint for a Topic?
- Can I Delete a Published Message?
- Does SMN Ensure That Messages Are Received by Subscription Endpoints?
- Will a Subscriber Receive the Same Message Multiple Times?
- Why Do Subscribers Fail to Receive Messages After I Publish Messages to a Topic?
- What Can I Do When Pictures in an Email Message Cannot Be Displayed?
- How Do I Obtain My Account ID?
- Appendix
- Change History
- API Reference (Kuala Lumpur Region)
-
User Guide (Ankara Region)
- Overview
- Getting Started
- Topic Management
- Subscription Management
- Message Template Management
- Permissions Management
- Quotas
-
FAQs
- What Are the Advantages of SMN?
- What Protocols Does SMN Support?
- What Are the Requirements for an SMN Topic Name?
- How Many Topics Can I Create?
- How Many Subscriptions Can Be Added to a Topic?
- How Many Messages Can Be Published to a Topic?
- How Many Message Templates Can I Create?
- Can I Add Subscriptions Using Multiple Protocols to a Topic?
- Can a Topic Creator Change Subscription Protocols in a Topic?
- Can I Change a Subscription Endpoint for a Topic?
- Can I Delete a Published Message?
- Does SMN Ensure That Messages Are Received by Subscription Endpoints?
- Will a Subscriber Receive the Same Message Multiple Times?
- Why Do Subscribers Fail to Receive Messages After I Publish Messages to a Topic?
- What Can I Do When Pictures in an Email Message Cannot Be Displayed?
- How Do I Obtain My Account ID?
- Appendix
- Change History
- API Reference (Ankara Region)
-
User Guide (ME-Abu Dhabi Region)
- General Reference
Copied.
Using FunctionGraph to Forward SMN Messages to Slack
Scenarios
This section described how to use FunctionGraph to forward SMN messages to Slack. Slack, developed by Slack Technologies, is cloud-based instant messaging software. Slack does not have an API to receive HTTPS messages sent from SMN. So, you cannot directly add a Slack subscription to receive SMN notifications. Instead, you need to use FunctionGraph to forward messages to a specified URL.
Prerequisites
- You have created an SMN message topic, for example, smn-test. For details, see Creating a Topic.
- You have downloaded Slack.
Procedure
To use FunctionGraph to send SMN messages to Slack, perform the following operations:
Configuring Slack
- Create or select a channel on Slack.
Figure 1 Creating a channel
- Choose Apps > Manage > Browse apps.
Figure 2 Choosing Apps
- Search for Incoming Webhooks and click Add.
Figure 3 Adding Incoming Webhooks
- Click Configuration to go to the configuration page and obtain the Webhook URL.
Figure 4 Clicking ConfigurationFigure 5 Obtaining the Webhook URL
- Save the obtained Webhook URL.
Figure 6 Saving the Webhook URL
Configuring FunctionGraph
- Log in to the FunctionGraph console. In the navigation pane, choose Functions > Function List.
- Click Create Function in the upper right corner and choose Select template.
- Select the template shown in Figure 7 and click Configure.
- Set the function name, select an agency, retain default values for other parameters, and click Create Function.
Figure 8 Configuring basic information
- On the configuration details page, click the Code tab and edit the code in index.py.
Figure 9 Editing the code
The following is an example of the code sent to Slack: (In actual use, set webhook_url to the Webhook URL obtained from Slack or perform other operations as required.)
# -*- coding:utf-8 -*- import json import requests def handler (event, context): # Common part: Construct the body fields required by the destination address. event contains all fields sent by SMN. payload = {'text': event["record"][0]["smn"]["message"]} # Forwarding part: Call a Slack API to forward messages to the Slack platform. try: webhook_url = 'Webhook URL obtained from Slack' response = requests.post(webhook_url, json=payload) response.raise_for_status() print('Message sent successfully') except requests.exceptions.RequestException as e: print(f"Error sending message to Slack: {e}") return event
- After the editing is complete, press Ctrl+S to save the modification and update the code.
- Click Create Trigger.
- Set the following parameters:
- Trigger Type: Select Simple Message Notification (SMN).
- Topic Name: Select a topic, for example, smn-test.
Figure 10 Creating a trigger - Click OK. After the topic is created, all messages sent to the topic are forwarded to the destination address through FunctionGraph.
Configuring SMN
- Log in to the SMN console. In the navigation pane, choose Topic Management > Topics.
- Locate the topic smn-test and click Add Subscription in the Operation column.
- Set the following parameters:
- Protocol: Select FunctionGraph (function).
- Endpoint: Select a created function, for example, smn-test.
Figure 11 Adding a subscription - Click OK.
- Locate the topic smn-test and click Publish Message in the Operation column.
- Set the following parameters:
- Message Format: Text
- Message Content: Enter the message content.
- Click OK.
Viewing the Received Message
After a message is published, you can receive the message on Slack. Figure 12 shows an example.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot