有奖:语音产品征文挑战赛火热进行中> HOT
文档中心 > 腾讯云微搭低代码 > 最佳实践 > 自定义代码调用企微 API

操作步骤

说明:
这里以发送应用消息接口为例。
1. 在 APIS 中创建企业微信开放服务。



2. 选中发送应用消息接口,复制对应的接口标识。



3. 再新建一个自定义代码的 APIS。



4. 输入以下代码。
说明:
自定义代码更多操作请参见 自定义代码-API
/**
* 使用 npm 包 node-fetch 发送http请求, 详细使用文档可以参考
* https://github.com/node-fetch/node-fetch
*/
const fetch = require('node-fetch');

module.exports = async function (params, context) {

const result = await context.callConnector({
name: 'API 标识',
// 传入 发送应用消息 接口标识
methodName: 'message_send',
params: {
"touser": "接受用户",
"msgtype": "消息类型",
"agentid": 应用ID,
"text": {
"content": "推送内容"
}
}, // 方法入参
});

return {
result
};
};